﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QLKhachSan.DTO;
using System.Data;
using System.Data.SqlClient;

namespace QLKhachSan.DAO
{
    public class DAO_Phong
    {
        public static void themPhong(DTO_Phong p)
        {
            string[] name = new string[7] { "@TenPhong","@ViTri","@TienIch","@MaLP","@MaKP","@Gia","@MaTrangThai" };
            object[] ob = new object[7] { p.TenPhong,p.ViTri,p.TienIch,p.MaLP,p.MaKP,p.Gia,p.MaTrangThai };
            clsKetNoi.ThucThiLenhCoTS("pr_ThemPhong", name, ob, 7);
        }
        public static DataTable hienthiDanhSachPhong()
        {
            return clsKetNoi.Load("pr_HienThiPhong");
        }
        public static void suaPhong(DTO_Phong p)
        {
            string[] name = new string[7] { "@TenPhong","@ViTri", "@TienIch", "@MaLP", "@MaKP", "@Gia", "@MaTrangThai" };
            object[] ob = new object[7] { p.TenPhong,p.ViTri, p.TienIch, p.MaLP, p.MaKP, p.Gia, p.MaTrangThai };
            clsKetNoi.ThucThiLenhCoTS("pr_SuaPhong", name, ob, 7);
        }
        public static void xoaPhong(DTO_Phong p)
        {
            string[] name = new string[1] { "@TenPhong" };
            object[] ob = new object[1] { p.TenPhong };
            clsKetNoi.ThucThiLenhCoTS("pr_XoaPhong", name, ob, 1);
        }
        public static DataTable hienthiDanhSachPhongTheoTenPhong()
        {
            return clsKetNoi.Load("pr_HienThiPhongTheoTenPhong");
        }
        public static DataTable hienthiDanhSachPhongTheoTrangThai(DTO_Phong p)
        {
            string[] name = new string[1] { "@MaTrangThai" };
            object[] ob = new object[1] { p.MaTrangThai };
            return clsKetNoi.LoadCoTS("pr_HienThiTrangThaiPhong", name, ob, 1);
        }
        public static void suaPhongTheoTrangThai(DTO_Phong p)
        {
            string[] name = new string[2] { "@TenPhong","@MaTrangThai" };
            object[] ob = new object[2] { p.TenPhong, p.MaTrangThai };
            clsKetNoi.ThucThiLenhCoTS("pr_SuaPhongTheoTrangThai", name, ob, 2);
        }
    
        public static DataTable TimKiemDSPhongTheoTienTich(string a)
        {
            string[] name = new string[1] { "@TienIch" };
            object[] ob = new object[1] { a };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoTienTich",name,ob,1);
        }
        
        public static DataTable TimKiemDSPhongTheoViTri(string a)
        {
            string[] name = new string[1] { "@ViTri" };
            object[] ob = new object[1] { a };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoViTri", name, ob, 1);
        }
        public static DataTable TimKiemDSPhongTheoTenKieuPhong(string a)
        {
            string[] name = new string[1] { "@TenKP" };
            object[] ob = new object[1] { a };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoTenKieuPhong", name, ob, 1);
        }
       
        public static DataTable TimKiemDSPhongTheoTenLoaiPhong(string a)
        {
            string[] name = new string[1] { "@TenLP" };
            object[] ob = new object[1] { a };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoTenLoaiPhong", name, ob, 1);
        }

        public static DataTable TimKiemDSPhongTheoKhoangGia(int giatu, int giaden)
        {
            string[] name = new string[2] { "@GiaTu","@GiaDen" };
            object[] ob = new object[2] { giatu,giaden };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoKhoangGia", name, ob, 2);
        }
      
        public static DataTable TimKiemDSPhongTheoKhoangNgayThue(DateTime NgayTu, DateTime NgayDen)
        {
            string[] name = new string[2] { "@NgayTu","@NgayDen" };
            object[] ob = new object[2] { NgayTu,NgayDen };
            return clsKetNoi.LoadCoTS("pr_TimKiemDSPhongTheoKhoangNgayThue", name, ob, 2);
        }
    }
}
